package com.hbx.residential_service.service.impl;

import com.github.pagehelper.PageHelper;
import com.hbx.residential_service.dao.UserDao;
import com.hbx.residential_service.domain.*;
import com.hbx.residential_service.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public List<User> findAll(int page, int size) throws Exception {
        PageHelper.startPage(page,size);
        return userDao.findAll(page,size);
    }

    @Override
    public User userLogin(String username, String userpwd) throws Exception {
        return userDao.userLogin(username,userpwd);
    }

    @Override
    public List<Complaint> userFindCp(String username, int page, int size) {
        PageHelper.startPage(page,size);
        return userDao.userFindCp(username,page,size);
    }

    @Override
    public List<Repair> userFindRp(String username, int page, int size) {
        PageHelper.startPage(page,size);
        return userDao.userFindRp(username,page,size);
    }

    @Override
    public List<Notice> FindNewNt() {
        return userDao.FindNewNt();
    }

    @Override
    public List<House> userFindHs(String username) {
        return userDao.userFindHs(username);
    }

    @Override
    public List<CarSite> userFindCs(String username) {
        return userDao.userFindCs(username);
    }

    @Override
    public List<Pay> userFindPy(String username) {
        return userDao.userFindPy(username);
    }

    @Override
    public String getUserSex(String username) {
        return userDao.getUserSex(username);
    }

    @Override
    public void addCp(Complaint complaint) {
        userDao.addCp(complaint);
    }

    @Override
    public User findByUserName(String username) {
        return userDao.findByUserName(username);
    }

    @Override
    public void addRp(Repair repair) {
        userDao.addRp(repair);
    }

    @Override
    public List<Pay> findNoPay(String username) {
        return userDao.findNoPay(username);
    }

    @Override
    public Pay findPayById(int payId) {
        return userDao.findPayById(payId);
    }

    @Override
    public void UpdatePay(Pay pay) {
        userDao.UpadatePay(pay);
    }

    @Override
    public void userRegister(User user) {
        userDao.userRegister(user);
    }

    @Override
    public void UpdatePwd(User user) {
        userDao.UpdatePwd(user);
    }

    @Override
    public User findUpdHouseById(int userid) {
        return userDao.findUpdHouseById(userid);
    }

    @Override
    public void UpdateById(User user) {
        userDao.UpdateById(user);
    }

    @Override
    public List<User> fsByUsername(String content, int page, int size) {
        PageHelper.startPage(page,size);
        return userDao.fsByUsername("%"+content+"%",page,size);
    }
}
